Skip to content

docs(examples): add security scanning utilities example#1

Open
vincent067 wants to merge 3 commits intomainfrom
feat/security-scanning-example
Open

docs(examples): add security scanning utilities example#1
vincent067 wants to merge 3 commits intomainfrom
feat/security-scanning-example

Conversation

@vincent067
Copy link
Owner

Hey there! 👋

I've been using execa in my security automation workflows and noticed the examples directory doesn't have any security-focused examples. Thought I'd contribute one that might help other developers integrating security tools into their Node.js scripts.

This example shows how to use execa with popular security scanning tools:

  • npm audit for dependency vulnerabilities
  • semgrep for static analysis
  • gitleaks for secret detection

The tricky part with security tools is they often exit with non-zero codes when they find issues (which is actually the success case for security scanning). The example shows how to handle this properly by checking error.stdout and parsing the results.

Happy to make any adjustments based on feedback! 😊

vincent067 and others added 3 commits March 20, 2026 18:10
Add examples/ directory with 4 common use cases:
- build-script.js: Build automation with error handling
- git-helpers.js: Git operation wrappers
- parallel-tasks.js: Running commands in parallel
- stream-processing.js: Output filtering with transforms

All examples use ES modules and are self-contained.
Add comprehensive documentation for Windows-specific fixes:
- PATHEXT support explanation with examples
- How Windows execution works under the hood
- Comparison table: automatic fixes vs shell mode
- Detailed breakdown of node-cross-spawn fixes
- Best practices for choosing between default mode and shell mode

Fixes sindresorhus#997
Add a new example demonstrating security scanning use cases with execa:
- npm audit integration for dependency vulnerability scanning
- semgrep integration for static analysis security testing
- gitleaks integration for secret detection in git history
- Comprehensive security report generation

This example shows how to:
- Handle JSON output from security tools
- Process exit codes (security tools often exit non-zero when issues found)
- Gracefully handle missing tools with helpful error messages
- Aggregate results from multiple security scans

The example follows the same patterns as other examples in the directory
and includes proper error handling, ES module syntax, and can be run
directly or imported as a module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant